#####################################################################
# File:         TopicListeners.py
# Product:      KnowledgeEngine
#
# Copyright:    Copyright (c) 2002, Faulkner Ltd.
# Author:       Brian Oliver
#
# Description:  This file defines the TopicListeners class to
#               manage a collection of registered MessageListeners
#               for a specified Topic.
#
# Note:         Topic, Filter and Group names are case-sensitive
#
# See Also:     Messaging, Message, MessageListener, GroupListeners,
#               FilterListeners
#####################################################################

#####################################################################
## KnowledgeEngine Library Imports
# (none)

#####################################################################
## Zope Library Imports
# (none)
 
#####################################################################
## Python Library Imports
# (none)

#####################################################################
## TopicListeners Class Definition
class TopicListeners:
    """
        A class to that stores the registered MessageListeners
        for a particular named Topic.
    """
        
    #---------------------------------------------------------------#
    
    #the name of the topic
    name = ""
    
    #the registered message listeners for the topic
    listeners = []  
    
    #---------------------------------------------------------------#

    def __init__(self, name):
        """
            Constructor for the Topic
        """
        
        self.name = name
        self.listeners = []
        
    #---------------------------------------------------------------#

    def getName(self):
        """
            Return the name of the topic
        """
        return self.name

    #---------------------------------------------------------------#
    
    def getListeners(self):
        """
            Return the list of registered MessageListeners for the topic
        """
        return self.listeners
    
    #---------------------------------------------------------------#

    def addListener(self, messageListener):
        """
            Adds the specified listener for the topic
        """
        self.listeners += [messageListener]        
        
    #---------------------------------------------------------------#

    def removeListener(self, messageListener):
        """
            Removed the specified listener from the topic
        """
        
        self.listeners.remove(messageListener) 

    #---------------------------------------------------------------#

#####################################################################
## Class Initialisation
# (none)
